import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: happyiu
 * Date: 2021-11-09
 * Time: 19:09
 */
public class TestDemo {

    public static int[] copyArray(int [] array){
        int [] copy = new int[array.length];
        for(int i = 0;i<array.length;i++){
            copy[i]=array[i];
        }
        return copy;
    }




    public static void main1(String[] args) {

        int [] array = {1,2,3,4,5,6};
//        int [] ret = copyArray(array);
//        int []ret = Arrays.copyOf(array,array.length);
        int []ret = Arrays.copyOfRange(array,1,3);
        System.out.println(Arrays.toString(ret));

    }
    public static void main2(String[] args) {

        int [] array = {1,2,3,4,5,6};
        int []copy = new int[array.length];
        System.arraycopy(array,0,copy,0,array.length);
        System.out.println(Arrays.toString(copy));

    }

    public static void main(String[] args) {

        int [] array = {1,2,3,4,5,6};
        int []copy = array.clone();

        System.out.println(Arrays.toString(copy));

    }
}
